package com.java.util;

import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.util.concurrent.TimeUnit;
interface IA{
    static void show(int a,int b){}
}

public class DateTests {
    public static void main(String[] args) {
        //瞬时对象(绝对时间对象)
        Instant now = Instant.now();
        System.out.println(now);
        //东八区
        Instant instant = now.plusMillis(TimeUnit.HOURS.toMillis(8));
        System.out.println(instant);

        System.out.println(ZoneId.getAvailableZoneIds());//获取可用时区
        System.out.println(ZoneId.systemDefault());//系统默认时区
        System.out.println(Instant.now().atZone(ZoneId.systemDefault()));//默认时区时间

        Instant start = Instant.now();
        try{Thread.sleep(1000);}catch (Exception e){}
        Instant end = Instant.now();
        Duration timeElapsed = Duration.between(start, end);
        System.out.println("Milliseconds: " + timeElapsed.toMillis());

    }
}
